home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / f2c / may_5_92.lha / f2c.VMay_5_1992 / libF77 / s_cmp.c < prev    next >
C/C++ Source or Header  |  1992-05-07  |  505b  |  39 lines

  1. #include "f2c.h"
  2.  
  3. integer s_cmp(a, b, la, lb)    /* compare two strings */
  4. register char *a, *b;
  5. ftnlen la, lb;
  6. {
  7. register char *aend, *bend;
  8. aend = a + la;
  9. bend = b + lb;
  10.  
  11. if(la <= lb)
  12.     {
  13.     while(a < aend)
  14.         if(*a != *b)
  15.             return( *a - *b );
  16.         else
  17.             { ++a; ++b; }
  18.  
  19.     while(b < bend)
  20.         if(*b != ' ')
  21.             return( ' ' - *b );
  22.         else    ++b;
  23.     }
  24.  
  25. else
  26.     {
  27.     while(b < bend)
  28.         if(*a == *b)
  29.             { ++a; ++b; }
  30.         else
  31.             return( *a - *b );
  32.     while(a < aend)
  33.         if(*a != ' ')
  34.             return(*a - ' ');
  35.         else    ++a;
  36.     }
  37. return(0);
  38. }
  39.